﻿using AnesSystem.Models;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace AnesSystem.Converters
{
    public class PrescriptionType2Name : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            try
            {
                if (value == null) return "";
                if (string.IsNullOrEmpty(value.ToString())) return value;
                ConfigPrescriptionTypesModel configPrescriptionTypesModel =
                    DataManager.Instance.ConfigPrescriptionTypesModelList.ToList().Find(
                        O => O.Code.Equals(value.ToString()));
                if (configPrescriptionTypesModel == null) return "";
                return configPrescriptionTypesModel.Name;
            }
            catch (Exception ex)
            {
                Common.LogHelper.Error(this.GetType(), ex);
                return value;

            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
           
            return value;
        }
    }
}
